﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Whir_System_Module_Sitemap_Sitemap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }
    protected void BindData()
    {
        string SqlTemp = "select columnID,parentID,columnName,url,isSinglePage,directory from Whir_Column where parentID = 0 order by sort asc";
        DataSet ds = Whir.SQLServerDAL.DbHelperSQL.Query(SqlTemp);
        Repeater1.DataSource = ds;
        Repeater1.DataBind();
    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //Repeater Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
        //string SqlStr = "select columnID,parentID,columnName,url,isSinglePage,directory from Whir_Column where parentID = " + DataBinder.Eval(e.Item.DataItem, "columnID") + " order by sort asc";
        //DataSet ds1 = Whir.SQLServerDAL.DbHelperSQL.Query(SqlStr);
        //Repeater2.DataSource = ds1;
        //Repeater2.DataBind();

        Literal Literal1 = (Literal)e.Item.FindControl("Literal1");
        string SqlStr = "select columnID,parentID,columnName,url,isSinglePage,directory from Whir_Column where parentID = " + DataBinder.Eval(e.Item.DataItem, "columnID") + " order by sort asc";
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(SqlStr).Tables[0];

        string StrTemp = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if ((bool)dt.Rows[0]["isSinglePage"] == true)
                StrTemp += "<td bgcolor=\"#FDFDFD\"><a href=\"" + Whir.Common.Settings.GetString("SystemPath") + dt.Rows[i]["directory"].ToString() + "/" + dt.Rows[i]["url"].ToString() + "\" class=\"agray\">" + dt.Rows[i]["columnName"].ToString() + "</a></td>";
            else
                StrTemp += "<td bgcolor=\"#FDFDFD\"><a href=\"" + Whir.Common.Settings.GetString("SystemPath") + "html/" + dt.Rows[i]["columnID"].ToString() + "/" + dt.Rows[i]["url"].ToString() + "\" class=\"agray\">" + dt.Rows[i]["columnName"].ToString() + "</a></td>";
        }
        Literal1.Text = StrTemp;
    }
}
